package com.tjy.farmer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjy.common.annotation.Log;
import com.tjy.common.core.controller.BaseController;
import com.tjy.common.core.domain.AjaxResult;
import com.tjy.common.enums.BusinessType;
import com.tjy.farmer.domain.BeeAreaInfo;
import com.tjy.farmer.service.IBeeAreaInfoService;
import com.tjy.common.utils.poi.ExcelUtil;
import com.tjy.common.core.page.TableDataInfo;

/**
 * 蜂区管理Controller
 * 
 * @author tjy
 * @date 2025-09-08
 */
@RestController
@RequestMapping("/farmer/beearea")
public class BeeAreaInfoController extends BaseController
{
    @Autowired
    private IBeeAreaInfoService beeAreaInfoService;

    /**
     * 查询蜂区管理列表
     */
    @PreAuthorize("@ss.hasPermi('farmer:beearea:list')")
    @GetMapping("/list")
    public TableDataInfo list(BeeAreaInfo beeAreaInfo)
    {
        startPage();
        List<BeeAreaInfo> list = beeAreaInfoService.selectBeeAreaInfoList(beeAreaInfo);
        return getDataTable(list);
    }

    /**
     * 导出蜂区管理列表
     */
    @PreAuthorize("@ss.hasPermi('farmer:beearea:export')")
    @Log(title = "蜂区管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BeeAreaInfo beeAreaInfo)
    {
        List<BeeAreaInfo> list = beeAreaInfoService.selectBeeAreaInfoList(beeAreaInfo);
        ExcelUtil<BeeAreaInfo> util = new ExcelUtil<BeeAreaInfo>(BeeAreaInfo.class);
        util.exportExcel(response, list, "蜂区管理数据");
    }

    /**
     * 获取蜂区管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('farmer:beearea:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(beeAreaInfoService.selectBeeAreaInfoById(id));
    }

    /**
     * 新增蜂区管理
     */
    @PreAuthorize("@ss.hasPermi('farmer:beearea:add')")
    @Log(title = "蜂区管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BeeAreaInfo beeAreaInfo)
    {
        return toAjax(beeAreaInfoService.insertBeeAreaInfo(beeAreaInfo));
    }

    /**
     * 修改蜂区管理
     */
    @PreAuthorize("@ss.hasPermi('farmer:beearea:edit')")
    @Log(title = "蜂区管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BeeAreaInfo beeAreaInfo)
    {
        return toAjax(beeAreaInfoService.updateBeeAreaInfo(beeAreaInfo));
    }

    /**
     * 删除蜂区管理
     */
    @PreAuthorize("@ss.hasPermi('farmer:beearea:remove')")
    @Log(title = "蜂区管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(beeAreaInfoService.deleteBeeAreaInfoByIds(ids));
    }
}
